package com.zhy.http.okhttp.callback;


import android.util.Log;

import okhttp3.Call;
import okhttp3.Request;

/**
 * Conpany:成都欧品在线电子商务有限公司技术服务中心
 * Auther:孙福义
 * Date: 2016/2/17
 * Effect: 作用描述
 */
public abstract  class IDBRequestCallBack<T> {
    public static final String TAG = "IDBRequestCallBack";

    /**
     * UI Thread
     *
     * @param request
     */
    public void onBefore(Request request) {
    }

    /**
     * UI Thread
     *
     * @param
     */
    public void onAfter() {
    }

    /**
     * UI Thread
     *
     * @param progress
     */
    public void inProgress(float progress) {

    }

    /**
     * Thread Pool Thread
     *
     * @param data
     */
    public abstract T parseNetworkResponse(String data) throws Exception;

    public abstract void onError(Call call, Exception e);

    public abstract void onResponse(T response);

    public abstract void onRequstResponse(T response, int code, String message);

    public static IDBRequestCallBack CALLBACK_DEFAULT = new IDBRequestCallBack() {



        @Override
        public Object parseNetworkResponse(String data) throws Exception {

            return data;
        }

        @Override
        public void onError(Call call, Exception e) {

        }

        @Override
        public void onResponse(Object response) {

        }

        @Override
        public void onRequstResponse(Object response, int code, String message) {

        }
    };
}
